# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=tar
pkgver=1.30
pkgrel=1
pkgdesc="Utility used to store, backup, and transport files"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/tar/tar.html"
license=('GPL3')
groups=('compression')
depends=('msys2-runtime' 'libiconv' 'libintl' 'sh')
makedepends=('libiconv-devel' 'gettext-devel')
options=('!emptydirs')
install=tar.install
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz{,.sig}
        1.29-mode-binary.patch
        tar-1.29-msys2.patch)
sha256sums=('f1bf92dbb1e1ab27911a861ea8dde8208ee774866c46c0bb6ead41f4d1f4d2d3'
            'SKIP'
            '50770e281d8b23c8d4ca301ea6f49962f01c55c89139157eb350f1d541052319'
            '5ad664084e67d737924ff889ab05bfd771454cbe526d9e28330f06c430ebf4f3')
validpgpkeys=('325F650C4C2B6AD58807327A3602B07F55D0C732') # Sergey Poznyakoff

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/1.29-mode-binary.patch
  patch -p1 -i ${srcdir}/tar-1.29-msys2.patch

  autoreconf -fi
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib/tar \
    --enable-backup-scripts
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check || true
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
}
